package com.zyzd.custom.widget.cardbagview;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zyzd.custom.R;


/**
 * Created by lzy on 2018/5/8 0008.
 * description ${TODO}
 * <p>
 * Changed by somebody on 2018/5/8 0008
 * description ${TODO}
 */
public class CardBagAdapter extends RecyclerView.Adapter<CardBagAdapter.CarBagHolder> {

    private final Context mContext;
    private final LayoutInflater mInflater;

    private String[] mDatas = {"香蕉", "苹果", "李子", "柠檬", "榴莲", "火龙果"};

    public CardBagAdapter(Context context) {
        mContext = context.getApplicationContext();
        mInflater = LayoutInflater.from(mContext);
    }

    @NonNull
    @Override
    public CarBagHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new CarBagHolder(mInflater.inflate(R.layout.item_cardbag, parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull CarBagHolder holder, int position) {
        holder.tvContent.setText(mDatas[position]);
    }

    @Override
    public int getItemCount() {
        return mDatas.length;
    }

    static class CarBagHolder extends RecyclerView.ViewHolder {

        final TextView tvContent;

        public CarBagHolder(View itemView) {
            super(itemView);
            tvContent = itemView.findViewById(R.id.tv_content);
        }
    }
}
